package com.book.demo.demo.dao;

import com.book.demo.demo.model.BookInfo;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Repository
public class BookDao {
    /**
     * 书籍数据层*/

    /**
     * 生成虚图书列表数据*/
    public List<BookInfo> mockData() {
        List<BookInfo> bookInfoList = new ArrayList<>();
        for(int i = 0; i < 15; i++) {
            BookInfo book = new BookInfo();
            book.setId(i);
            book.setBookName("书名" + i);
            book.setAuthor("作者" + i);
            book.setCount(new Random().nextInt(200));
            book.setPrice(new BigDecimal(new Random().nextInt(100)));
            book.setPublish("出版社" + i);
            book.setStatus(i%5 == 0 ? 1 : 2);
            book.setStatusCN(book.getStatus() == 1 ? "可借阅" : "不可借阅");
            bookInfoList.add(book);
        }
        return bookInfoList;
    }
}
